package dev.bong.mapper;

import com.github.pagehelper.Page;
import dev.bong.annotation.AutoFill;
import dev.bong.dto.UserPageQueryDTO;
import dev.bong.enumeration.OperationType;

import dev.bong.pojo.entity.User;

import dev.bong.vo.UserVo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {


    @Select("select username from user where id=#{id}")
    String getNameById(Integer id);


    User getUserById(Integer id);


    User getUserByUserAccount(String account);

    Page<UserVo> pageQuery(UserPageQueryDTO dto);


    @AutoFill(value = OperationType.INSERT)
    @Insert("insert into user (username, user_account, user_password, major, " +
            "class_name, professional_title, role_id, " +
            "create_by, create_time, update_by, update_time) " +
            "values (#{userName},#{userAccount},#{userPassword},#{major}," +
            "#{className},#{professionalTitle},#{roleId}," +
            "#{createBy},#{createTime},#{updateBy},#{updateTime})")
    void addUser(User user);

    @AutoFill(value = OperationType.UPDATE)
    void updateUser(User user);




    @Delete("delete from user where id=#{id}")
    void deleteUserById(Integer id);

    @Delete("delete from user where id in #{ids}")
    void deleteUserByIds(List<Integer> ids);


    void deleteUser(List<Integer> ids);

    void resetPassword(List<Integer> ids,String password);
}
